﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Data.Schema.Sql.SchemaModel;

namespace TFDP.Common
{
    public static class ProcedureExtensions
    {
        public static List<ISqlSubroutineParameter> GetParameters(this ISqlProcedure procedure, ParameterFlags flags = ParameterFlags.All)
        {
            var matches = procedure.Parameters
                .Where(p => ((flags & ParameterFlags.All) == ParameterFlags.All) ||
                            (p.IsOutput && ((flags & ParameterFlags.Output) == ParameterFlags.Output))
                      )
                .Select(p => p);

            return matches.ToList();
        }
    }

    [Flags]
    public enum ParameterFlags
    {
        Input = 1,
        Output = 2,
        All = Input | Output
    }
}
